<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="../lib/vue.js"></script>
    <title>跑马灯</title>
</head>
<body>
    <div id="app">
        <input type="button" value="来咯，来咯"  @click="gogo">
        <input type="button" value="给我停"  @click="stop"> 
        <h1 v-text>{{msg}}</h1>
    </div>
</body>
<script>
    var vm=new Vue({
        el:"#app",
        data:{ 
            msg:"正在前往支援，保护我方姜子牙！！",
            
        },
        methods: {
            gogo(){
                if(this.intervalID!=null)return
                this.intervalID=setInterval(()=>{
                var start=this.msg.substring(0,1)
                var end=this.msg.substring(1)
                this.msg=end+start
            },400);
        },
        stop(){
            clearInterval(this.intervalID)
            this.intervalID=null
        }
        },
        })
</script>
</html>